<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::AssetTagHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::AssetTagHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper_rb.html">
                vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
This module provides methods for generating HTML that links views to assets
such as images, javascripts, stylesheets, and feeds. These methods do not
verify the assets exist before linking to them.
</p>
<h3>Using asset hosts</h3>
<p>
By default, <a href="../../Rails.html">Rails</a> links to these assets on
the current host in the public folder, but you can direct <a
href="../../Rails.html">Rails</a> to link to assets from a dedicated assets
server by setting ActionController::Base.asset_host in your environment.rb.
For example, let&#8216;s say your asset host is assets.example.com.
</p>
<pre>
  ActionController::Base.asset_host = &quot;assets.example.com&quot;
  image_tag(&quot;rails.png&quot;)
    =&gt; &lt;img src=&quot;http://assets.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;
  stylesheet_include_tag(&quot;application&quot;)
    =&gt; &lt;link href=&quot;http://assets.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
<p>
This is useful since browsers typically open at most two connections to a
single host, which means your assets often wait in single file for their
turn to load. You can alleviate this by using a %d wildcard in
<tt>asset_host</tt> (for example, &quot;assets%d.example.com&quot;) to
automatically distribute asset requests among four hosts (e.g.,
assets0.example.com through assets3.example.com) so browsers will open
eight connections rather than two.
</p>
<pre>
  image_tag(&quot;rails.png&quot;)
    =&gt; &lt;img src=&quot;http://assets0.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;
  stylesheet_include_tag(&quot;application&quot;)
    =&gt; &lt;link href=&quot;http://assets3.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
<p>
To do this, you can either setup 4 actual hosts, or you can use wildcard
DNS to CNAME the wildcard to a single asset host. You can read more about
setting up your DNS CNAME records from your ISP.
</p>
<p>
Note: This is purely a browser performance optimization and is not meant
for server load balancing. See <a
href="http://www.die.net/musings/page_load_time">www.die.net/musings/page_load_time</a>/
for background.
</p>
<p>
Alternatively, you can exert more control over the asset host by setting
<tt>asset_host</tt> to a proc that takes a single source argument. This is
useful if you are unable to setup 4 actual hosts or have fewer/more than 4
hosts. The example proc below generates <a
href="http://assets1.example.com">assets1.example.com</a> and <a
href="http://assets2.example.com">assets2.example.com</a> randomly.
</p>
<pre>
  ActionController::Base.asset_host = Proc.new { |source| &quot;http://assets#{rand(2) + 1}.example.com&quot; }
  image_tag(&quot;rails.png&quot;)
    =&gt; &lt;img src=&quot;http://assets2.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;
  stylesheet_include_tag(&quot;application&quot;)
    =&gt; &lt;link href=&quot;http://assets1.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
<p>
The proc takes a single <tt>source</tt> parameter which is the path of the
source asset. This can be used to generate a particular asset host
depending on the asset path.
</p>
<pre>
   ActionController::Base.asset_host = Proc.new { |source|
     if source.starts_with?('/images')
       &quot;http://images.example.com&quot;
     else
       &quot;http://assets.example.com&quot;
     end
   }
  image_tag(&quot;rails.png&quot;)
    =&gt; &lt;img src=&quot;http://images.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;
  stylesheet_include_tag(&quot;application&quot;)
    =&gt; &lt;link href=&quot;http://assets.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
<h3>Using asset timestamps</h3>
<p>
By default, <a href="../../Rails.html">Rails</a> will append all asset
paths with that asset&#8216;s timestamp. This allows you to set a
cache-expiration date for the asset far into the future, but still be able
to instantly invalidate it by simply updating the file (and hence updating
the timestamp, which then updates the URL as the timestamp is part of that,
which in turn busts the cache).
</p>
<p>
It&#8216;s the responsibility of the web server you use to set the
far-future expiration date on cache assets that you need to take advantage
of this feature. Here&#8216;s an example for Apache:
</p>
<p>
# Asset Expiration ExpiresActive On &lt;FilesMatch
&quot;\.(ico|gif|jpe?g|png|js|css)$&quot;&gt;
</p>
<pre>
  ExpiresDefault &quot;access plus 1 year&quot;
</pre>
<p>
&lt;/FilesMatch&gt;
</p>
<p>
Also note that in order for this to work, all your application servers must
return the same timestamps. This means that they must have their clocks
synchronized. If one of them drift out of sync, you&#8216;ll see different
timestamps at random and the cache won&#8216;t work. Which means that the
browser will request the same assets over and over again even thought they
didn&#8216;t change. You can use something like Live HTTP Headers for
Firefox to verify that the cache is indeed working (and that the assets are
not being requested over and over).
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001021">auto_discovery_link_tag</a>&nbsp;&nbsp;
      <a href="#M001029">image_path</a>&nbsp;&nbsp;
      <a href="#M001031">image_tag</a>&nbsp;&nbsp;
      <a href="#M001024">javascript_include_tag</a>&nbsp;&nbsp;
      <a href="#M001022">javascript_path</a>&nbsp;&nbsp;
      <a href="#M001030">path_to_image</a>&nbsp;&nbsp;
      <a href="#M001023">path_to_javascript</a>&nbsp;&nbsp;
      <a href="#M001027">path_to_stylesheet</a>&nbsp;&nbsp;
      <a href="#M001025">register_javascript_include_default</a>&nbsp;&nbsp;
      <a href="#M001028">stylesheet_link_tag</a>&nbsp;&nbsp;
      <a href="#M001026">stylesheet_path</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">ASSETS_DIR</td>
          <td>=</td>
          <td class="context-item-value">defined?(RAILS_ROOT) ? &quot;#{RAILS_ROOT}/public&quot; : &quot;public&quot;</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">JAVASCRIPTS_DIR</td>
          <td>=</td>
          <td class="context-item-value">&quot;#{ASSETS_DIR}/javascripts&quot;</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">STYLESHEETS_DIR</td>
          <td>=</td>
          <td class="context-item-value">&quot;#{ASSETS_DIR}/stylesheets&quot;</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">JAVASCRIPT_DEFAULT_SOURCES</td>
          <td>=</td>
          <td class="context-item-value">['prototype', 'effects', 'dragdrop', 'controls'] unless const_defined?(:JAVASCRIPT_DEFAULT_SOURCES)</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001025" class="method-detail">
        <a name="M001025"></a>

        <div class="method-heading">
          <a href="#M001025" class="method-signature">
          <span class="method-name">register_javascript_include_default</span><span class="method-args">(*sources)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Register one or more additional JavaScript files to be included when <tt><a
href="AssetTagHelper.html#M001024">javascript_include_tag</a>
:defaults</tt> is called. This method is typically intended to be called
from plugin initialization to register additional .js files that the plugin
installed in <tt>public/javascripts</tt>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001025-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001025-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 241</span>
241:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">register_javascript_include_default</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">sources</span>)
242:         <span class="ruby-ivar">@@javascript_default_sources</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">sources</span>)
243:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001021" class="method-detail">
        <a name="M001021"></a>

        <div class="method-heading">
          <a href="#M001021" class="method-signature">
          <span class="method-name">auto_discovery_link_tag</span><span class="method-args">(type = :rss, url_options = {}, tag_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a link tag that browsers and news readers can use to auto-detect an
RSS or ATOM feed. The <tt>type</tt> can either be <tt>:rss</tt> (default)
or <tt>:atom</tt>. Control the link options in url_for format using the
<tt>url_options</tt>. You can modify the LINK tag itself in
<tt>tag_options</tt>.
</p>
<h4>Options:</h4>
<ul>
<li><tt>:rel</tt> - Specify the relation of this link, defaults to
&quot;alternate&quot;

</li>
<li><tt>:type</tt> - Override the auto-generated mime type

</li>
<li><tt>:title</tt> - Specify the title of the link, defaults to the
<tt>type</tt>

</li>
</ul>
<h4>Examples</h4>
<pre>
 auto_discovery_link_tag # =&gt;
    &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;RSS&quot; href=&quot;http://www.currenthost.com/controller/action&quot; /&gt;
 auto_discovery_link_tag(:atom) # =&gt;
    &lt;link rel=&quot;alternate&quot; type=&quot;application/atom+xml&quot; title=&quot;ATOM&quot; href=&quot;http://www.currenthost.com/controller/action&quot; /&gt;
 auto_discovery_link_tag(:rss, {:action =&gt; &quot;feed&quot;}) # =&gt;
    &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;RSS&quot; href=&quot;http://www.currenthost.com/controller/feed&quot; /&gt;
 auto_discovery_link_tag(:rss, {:action =&gt; &quot;feed&quot;}, {:title =&gt; &quot;My RSS&quot;}) # =&gt;
    &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;My RSS&quot; href=&quot;http://www.currenthost.com/controller/feed&quot; /&gt;
 auto_discovery_link_tag(:rss, {:controller =&gt; &quot;news&quot;, :action =&gt; &quot;feed&quot;}) # =&gt;
    &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;RSS&quot; href=&quot;http://www.currenthost.com/news/feed&quot; /&gt;
 auto_discovery_link_tag(:rss, &quot;http://www.example.com/feed.rss&quot;, {:title =&gt; &quot;Example RSS&quot;}) # =&gt;
    &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;Example RSS&quot; href=&quot;http://www.example.com/feed&quot; /&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001021-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001021-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 116</span>
116:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">auto_discovery_link_tag</span>(<span class="ruby-identifier">type</span> = <span class="ruby-identifier">:rss</span>, <span class="ruby-identifier">url_options</span> = {}, <span class="ruby-identifier">tag_options</span> = {})
117:         <span class="ruby-identifier">tag</span>(
118:           <span class="ruby-value str">&quot;link&quot;</span>,
119:           <span class="ruby-value str">&quot;rel&quot;</span>   =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">tag_options</span>[<span class="ruby-identifier">:rel</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;alternate&quot;</span>,
120:           <span class="ruby-value str">&quot;type&quot;</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">tag_options</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Mime</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">lookup_by_extension</span>(<span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_s</span>,
121:           <span class="ruby-value str">&quot;title&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">tag_options</span>[<span class="ruby-identifier">:title</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>,
122:           <span class="ruby-value str">&quot;href&quot;</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">url_options</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">url_for</span>(<span class="ruby-identifier">url_options</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:only_path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>)) <span class="ruby-operator">:</span> <span class="ruby-identifier">url_options</span>
123:         )
124:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001029" class="method-detail">
        <a name="M001029"></a>

        <div class="method-heading">
          <a href="#M001029" class="method-signature">
          <span class="method-name">image_path</span><span class="method-args">(source)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Computes the path to an image asset in the public images directory. Full
paths from the document root will be passed through. Used internally by <a
href="AssetTagHelper.html#M001031">image_tag</a> to build the image path.
</p>
<h4>Examples</h4>
<pre>
  image_path(&quot;edit&quot;)                                         # =&gt; /images/edit
  image_path(&quot;edit.png&quot;)                                     # =&gt; /images/edit.png
  image_path(&quot;icons/edit.png&quot;)                               # =&gt; /images/icons/edit.png
  image_path(&quot;/icons/edit.png&quot;)                              # =&gt; /icons/edit.png
  image_path(&quot;http://www.railsapplication.com/img/edit.png&quot;) # =&gt; http://www.railsapplication.com/img/edit.png
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001029-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001029-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 344</span>
344:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image_path</span>(<span class="ruby-identifier">source</span>)
345:         <span class="ruby-identifier">compute_public_path</span>(<span class="ruby-identifier">source</span>, <span class="ruby-value str">'images'</span>)
346:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001031" class="method-detail">
        <a name="M001031"></a>

        <div class="method-heading">
          <a href="#M001031" class="method-signature">
          <span class="method-name">image_tag</span><span class="method-args">(source, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an html image tag for the <tt>source</tt>. The <tt>source</tt> can
be a full path or a file that exists in your public images directory.
</p>
<h4>Options</h4>
<p>
You can add HTML attributes using the <tt>options</tt>. The
<tt>options</tt> supports three additional keys for convenience and
conformance:
</p>
<ul>
<li><tt>:alt</tt> - If no alt text is given, the file name part of the
<tt>source</tt> is used (capitalized and without the extension)

</li>
<li><tt>:size</tt> - Supplied as &quot;{Width}x{Height}&quot;, so
&quot;30x45&quot; becomes width=&quot;30&quot; and height=&quot;45&quot;.
<tt>:size</tt> will be ignored if the value is not in the correct format.

</li>
<li><tt>:mouseover</tt> - Set an alternate image to be used when the
onmouseover event is fired, and sets the original image to be replaced
onmouseout. This can be used to implement an easy image toggle that fires
on onmouseover.

</li>
</ul>
<h4>Examples</h4>
<pre>
 image_tag(&quot;icon&quot;)  # =&gt;
   &lt;img src=&quot;/images/icon&quot; alt=&quot;Icon&quot; /&gt;
 image_tag(&quot;icon.png&quot;)  # =&gt;
   &lt;img src=&quot;/images/icon.png&quot; alt=&quot;Icon&quot; /&gt;
 image_tag(&quot;icon.png&quot;, :size =&gt; &quot;16x10&quot;, :alt =&gt; &quot;Edit Entry&quot;)  # =&gt;
   &lt;img src=&quot;/images/icon.png&quot; width=&quot;16&quot; height=&quot;10&quot; alt=&quot;Edit Entry&quot; /&gt;
 image_tag(&quot;/icons/icon.gif&quot;, :size =&gt; &quot;16x16&quot;)  # =&gt;
   &lt;img src=&quot;/icons/icon.gif&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;Icon&quot; /&gt;
 image_tag(&quot;/icons/icon.gif&quot;, :height =&gt; '32', :width =&gt; '32') # =&gt;
   &lt;img alt=&quot;Icon&quot; height=&quot;32&quot; src=&quot;/icons/icon.gif&quot; width=&quot;32&quot; /&gt;
 image_tag(&quot;/icons/icon.gif&quot;, :class =&gt; &quot;menu_icon&quot;) # =&gt;
   &lt;img alt=&quot;Icon&quot; class=&quot;menu_icon&quot; src=&quot;/icons/icon.gif&quot; /&gt;
 image_tag(&quot;mouse.png&quot;, :mouseover =&gt; &quot;/images/mouse_over.png&quot;) # =&gt;
   &lt;img src=&quot;/images/mouse.png&quot; onmouseover=&quot;this.src='/images/mouse_over.png'&quot; onmouseout=&quot;this.src='/images/mouse.png'&quot; alt=&quot;Mouse&quot; /&gt;
 image_tag(&quot;mouse.png&quot;, :mouseover =&gt; image_path(&quot;mouse_over.png&quot;)) # =&gt;
   &lt;img src=&quot;/images/mouse.png&quot; onmouseover=&quot;this.src='/images/mouse_over.png'&quot; onmouseout=&quot;this.src='/images/mouse.png'&quot; alt=&quot;Mouse&quot; /&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001031-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001031-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 382</span>
382:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image_tag</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span> = {})
383:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys!</span>
384: 
385:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:src</span>] = <span class="ruby-identifier">path_to_image</span>(<span class="ruby-identifier">source</span>)
386:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:alt</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:src</span>], <span class="ruby-value str">'.*'</span>).<span class="ruby-identifier">split</span>(<span class="ruby-value str">'.'</span>).<span class="ruby-identifier">first</span>.<span class="ruby-identifier">capitalize</span>
387: 
388:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:size</span>)
389:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:width</span>], <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:height</span>] = <span class="ruby-identifier">size</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;x&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">%r{^\d+x\d+$}</span>
390:         <span class="ruby-keyword kw">end</span>
391: 
392:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mouseover</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:mouseover</span>)
393:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:onmouseover</span>] = <span class="ruby-node">&quot;this.src='#{image_path(mouseover)}'&quot;</span>
394:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:onmouseout</span>]  = <span class="ruby-node">&quot;this.src='#{image_path(options[:src])}'&quot;</span>
395:         <span class="ruby-keyword kw">end</span>
396: 
397:         <span class="ruby-identifier">tag</span>(<span class="ruby-value str">&quot;img&quot;</span>, <span class="ruby-identifier">options</span>)
398:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001024" class="method-detail">
        <a name="M001024"></a>

        <div class="method-heading">
          <a href="#M001024" class="method-signature">
          <span class="method-name">javascript_include_tag</span><span class="method-args">(*sources)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an html script tag for each of the <tt>sources</tt> provided. You
can pass in the filename (.js extension is optional) of javascript files
that exist in your public/javascripts directory for inclusion into the
current page or you can pass the full path relative to your document root.
To include the Prototype and Scriptaculous javascript libraries in your
application, pass <tt>:defaults</tt> as the source. When using :defaults,
if an <tt>application.js</tt> file exists in your public javascripts
directory, it will be included as well. You can modify the html attributes
of the script tag by passing a hash as the last argument.
</p>
<h4>Examples</h4>
<pre>
  javascript_include_tag &quot;xmlhr&quot; # =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/xmlhr.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag &quot;xmlhr.js&quot; # =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/xmlhr.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag &quot;common.javascript&quot;, &quot;/elsewhere/cools&quot; # =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/common.javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/elsewhere/cools.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag &quot;http://www.railsapplication.com/xmlhr&quot; # =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;http://www.railsapplication.com/xmlhr.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag &quot;http://www.railsapplication.com/xmlhr.js&quot; # =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;http://www.railsapplication.com/xmlhr.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag :defaults # =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/prototype.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/effects.js&quot;&gt;&lt;/script&gt;
    ...
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/application.js&quot;&gt;&lt;/script&gt;
</pre>
<ul>
<li>= The application.js file is only referenced if it exists

</li>
</ul>
<p>
Though it&#8216;s not really recommended practice, if you need to extend
the default JavaScript set for any reason (e.g., you&#8216;re going to be
using a certain .js file in every action), then take a look at the <a
href="AssetTagHelper.html#M001025">register_javascript_include_default</a>
method.
</p>
<p>
You can also include all javascripts in the javascripts directory using
<tt>:all</tt> as the source:
</p>
<pre>
  javascript_include_tag :all # =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/prototype.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/effects.js&quot;&gt;&lt;/script&gt;
    ...
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/application.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/shop.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/checkout.js&quot;&gt;&lt;/script&gt;
</pre>
<p>
Note that the default javascript files will be included first. So Prototype
and Scriptaculous are available to all subsequently included files.
</p>
<h2>Caching multiple javascripts into one</h2>
<p>
You can also cache multiple javascripts into one file, which requires less
HTTP connections to download and can better be compressed by gzip (leading
to faster transfers). Caching will only happen if
ActionController::Base.perform_caching is set to <tt>true</tt> (which is
the case by default for the <a href="../../Rails.html">Rails</a> production
environment, but not for the development environment).
</p>
<h4>Examples</h4>
<pre>
  javascript_include_tag :all, :cache =&gt; true # when ActionController::Base.perform_caching is false =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/prototype.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/effects.js&quot;&gt;&lt;/script&gt;
    ...
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/application.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/shop.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/checkout.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag :all, :cache =&gt; true # when ActionController::Base.perform_caching is true =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/all.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag &quot;prototype&quot;, &quot;cart&quot;, &quot;checkout&quot;, :cache =&gt; &quot;shop&quot; # when ActionController::Base.perform_caching is false =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/prototype.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/cart.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/checkout.js&quot;&gt;&lt;/script&gt;

  javascript_include_tag &quot;prototype&quot;, &quot;cart&quot;, &quot;checkout&quot;, :cache =&gt; &quot;shop&quot; # when ActionController::Base.perform_caching is false =&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/shop.js&quot;&gt;&lt;/script&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001024-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001024-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 222</span>
222:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">javascript_include_tag</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">sources</span>)
223:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">sources</span>.<span class="ruby-identifier">extract_options!</span>.<span class="ruby-identifier">stringify_keys</span>
224:         <span class="ruby-identifier">cache</span>   = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;cache&quot;</span>)
225: 
226:         <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">perform_caching</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">cache</span>
227:           <span class="ruby-identifier">joined_javascript_name</span> = (<span class="ruby-identifier">cache</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;all&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">cache</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;.js&quot;</span>
228:           <span class="ruby-identifier">joined_javascript_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">JAVASCRIPTS_DIR</span>, <span class="ruby-identifier">joined_javascript_name</span>)
229: 
230:           <span class="ruby-identifier">write_asset_file_contents</span>(<span class="ruby-identifier">joined_javascript_path</span>, <span class="ruby-identifier">compute_javascript_paths</span>(<span class="ruby-identifier">sources</span>))
231:           <span class="ruby-identifier">javascript_src_tag</span>(<span class="ruby-identifier">joined_javascript_name</span>, <span class="ruby-identifier">options</span>)
232:         <span class="ruby-keyword kw">else</span>
233:           <span class="ruby-identifier">expand_javascript_sources</span>(<span class="ruby-identifier">sources</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">source</span><span class="ruby-operator">|</span> <span class="ruby-identifier">javascript_src_tag</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
234:         <span class="ruby-keyword kw">end</span>
235:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001022" class="method-detail">
        <a name="M001022"></a>

        <div class="method-heading">
          <a href="#M001022" class="method-signature">
          <span class="method-name">javascript_path</span><span class="method-args">(source)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Computes the path to a javascript asset in the public javascripts
directory. If the <tt>source</tt> filename has no extension, .js will be
appended. Full paths from the document root will be passed through. Used
internally by <a
href="AssetTagHelper.html#M001024">javascript_include_tag</a> to build the
script path.
</p>
<h4>Examples</h4>
<pre>
  javascript_path &quot;xmlhr&quot; # =&gt; /javascripts/xmlhr.js
  javascript_path &quot;dir/xmlhr.js&quot; # =&gt; /javascripts/dir/xmlhr.js
  javascript_path &quot;/dir/xmlhr&quot; # =&gt; /dir/xmlhr.js
  javascript_path &quot;http://www.railsapplication.com/js/xmlhr&quot; # =&gt; http://www.railsapplication.com/js/xmlhr.js
  javascript_path &quot;http://www.railsapplication.com/js/xmlhr.js&quot; # =&gt; http://www.railsapplication.com/js/xmlhr.js
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001022-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001022-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 137</span>
137:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">javascript_path</span>(<span class="ruby-identifier">source</span>)
138:         <span class="ruby-identifier">compute_public_path</span>(<span class="ruby-identifier">source</span>, <span class="ruby-value str">'javascripts'</span>, <span class="ruby-value str">'js'</span>)
139:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001030" class="method-detail">
        <a name="M001030"></a>

        <div class="method-heading">
          <span class="method-name">path_to_image</span><span class="method-args">(source)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="AssetTagHelper.html#M001029">image_path</a>
</p>
        </div>
      </div>

      <div id="method-M001023" class="method-detail">
        <a name="M001023"></a>

        <div class="method-heading">
          <span class="method-name">path_to_javascript</span><span class="method-args">(source)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="AssetTagHelper.html#M001022">javascript_path</a>
</p>
        </div>
      </div>

      <div id="method-M001027" class="method-detail">
        <a name="M001027"></a>

        <div class="method-heading">
          <span class="method-name">path_to_stylesheet</span><span class="method-args">(source)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="AssetTagHelper.html#M001026">stylesheet_path</a>
</p>
        </div>
      </div>

      <div id="method-M001028" class="method-detail">
        <a name="M001028"></a>

        <div class="method-heading">
          <a href="#M001028" class="method-signature">
          <span class="method-name">stylesheet_link_tag</span><span class="method-args">(*sources)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a stylesheet link tag for the sources specified as arguments. If
you don&#8216;t specify an extension, .css will be appended automatically.
You can modify the link attributes by passing a hash as the last argument.
</p>
<h4>Examples</h4>
<pre>
  stylesheet_link_tag &quot;style&quot; # =&gt;
    &lt;link href=&quot;/stylesheets/style.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag &quot;style.css&quot; # =&gt;
    &lt;link href=&quot;/stylesheets/style.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag &quot;http://www.railsapplication.com/style.css&quot; # =&gt;
    &lt;link href=&quot;http://www.railsapplication.com/style.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag &quot;style&quot;, :media =&gt; &quot;all&quot; # =&gt;
    &lt;link href=&quot;/stylesheets/style.css&quot; media=&quot;all&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag &quot;style&quot;, :media =&gt; &quot;print&quot; # =&gt;
    &lt;link href=&quot;/stylesheets/style.css&quot; media=&quot;print&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag &quot;random.styles&quot;, &quot;/css/stylish&quot; # =&gt;
    &lt;link href=&quot;/stylesheets/random.styles&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;link href=&quot;/css/stylish.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
<p>
You can also include all styles in the stylesheet directory using :all as
the source:
</p>
<pre>
  stylesheet_link_tag :all # =&gt;
    &lt;link href=&quot;/stylesheets/style1.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;link href=&quot;/stylesheets/styleB.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;link href=&quot;/stylesheets/styleX2.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
<h2>Caching multiple stylesheets into one</h2>
<p>
You can also cache multiple stylesheets into one file, which requires less
HTTP connections and can better be compressed by gzip (leading to faster
transfers). Caching will only happen if
ActionController::Base.perform_caching is set to true (which is the case by
default for the <a href="../../Rails.html">Rails</a> production
environment, but not for the development environment). Examples:
</p>
<h4>Examples</h4>
<pre>
  stylesheet_link_tag :all, :cache =&gt; true # when ActionController::Base.perform_caching is false =&gt;
    &lt;link href=&quot;/stylesheets/style1.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;link href=&quot;/stylesheets/styleB.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;link href=&quot;/stylesheets/styleX2.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag :all, :cache =&gt; true # when ActionController::Base.perform_caching is true =&gt;
    &lt;link href=&quot;/stylesheets/all.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag &quot;shop&quot;, &quot;cart&quot;, &quot;checkout&quot;, :cache =&gt; &quot;payment&quot; # when ActionController::Base.perform_caching is false =&gt;
    &lt;link href=&quot;/stylesheets/shop.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;link href=&quot;/stylesheets/cart.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;link href=&quot;/stylesheets/checkout.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

  stylesheet_link_tag &quot;shop&quot;, &quot;cart&quot;, &quot;checkout&quot;, :cache =&gt; &quot;payment&quot; # when ActionController::Base.perform_caching is true =&gt;
    &lt;link href=&quot;/stylesheets/payment.css&quot;  media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001028-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001028-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 319</span>
319:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stylesheet_link_tag</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">sources</span>)
320:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">sources</span>.<span class="ruby-identifier">extract_options!</span>.<span class="ruby-identifier">stringify_keys</span>
321:         <span class="ruby-identifier">cache</span>   = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;cache&quot;</span>)
322: 
323:         <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">perform_caching</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">cache</span>
324:           <span class="ruby-identifier">joined_stylesheet_name</span> = (<span class="ruby-identifier">cache</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;all&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">cache</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;.css&quot;</span>
325:           <span class="ruby-identifier">joined_stylesheet_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">STYLESHEETS_DIR</span>, <span class="ruby-identifier">joined_stylesheet_name</span>)
326: 
327:           <span class="ruby-identifier">write_asset_file_contents</span>(<span class="ruby-identifier">joined_stylesheet_path</span>, <span class="ruby-identifier">compute_stylesheet_paths</span>(<span class="ruby-identifier">sources</span>))
328:           <span class="ruby-identifier">stylesheet_tag</span>(<span class="ruby-identifier">joined_stylesheet_name</span>, <span class="ruby-identifier">options</span>)
329:         <span class="ruby-keyword kw">else</span>
330:           <span class="ruby-identifier">expand_stylesheet_sources</span>(<span class="ruby-identifier">sources</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">source</span><span class="ruby-operator">|</span> <span class="ruby-identifier">stylesheet_tag</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
331:         <span class="ruby-keyword kw">end</span>
332:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001026" class="method-detail">
        <a name="M001026"></a>

        <div class="method-heading">
          <a href="#M001026" class="method-signature">
          <span class="method-name">stylesheet_path</span><span class="method-args">(source)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Computes the path to a stylesheet asset in the public stylesheets
directory. If the <tt>source</tt> filename has no extension, .css will be
appended. Full paths from the document root will be passed through. Used
internally by <a href="AssetTagHelper.html#M001028">stylesheet_link_tag</a>
to build the stylesheet path.
</p>
<h4>Examples</h4>
<pre>
  stylesheet_path &quot;style&quot; # =&gt; /stylesheets/style.css
  stylesheet_path &quot;dir/style.css&quot; # =&gt; /stylesheets/dir/style.css
  stylesheet_path &quot;/dir/style.css&quot; # =&gt; /dir/style.css
  stylesheet_path &quot;http://www.railsapplication.com/css/style&quot; # =&gt; http://www.railsapplication.com/css/style.css
  stylesheet_path &quot;http://www.railsapplication.com/css/style.js&quot; # =&gt; http://www.railsapplication.com/css/style.css
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001026-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001026-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 260</span>
260:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stylesheet_path</span>(<span class="ruby-identifier">source</span>)
261:         <span class="ruby-identifier">compute_public_path</span>(<span class="ruby-identifier">source</span>, <span class="ruby-value str">'stylesheets'</span>, <span class="ruby-value str">'css'</span>)
262:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>